﻿Imports Entities
Public Class GuiaDAL
    Public Shared Function Create(ByVal zObject As GUIAS) As GUIAS
        Try
            Using bd As New gas_gasdesuvecinoEntities
                bd.GUIAS.Add(zObject)
                bd.SaveChanges()
                Return zObject
            End Using
        Catch ex As Exception
            Debug.Print("GuiaDAL.Create() " + ex.Message)
            Return Nothing
        End Try
    End Function
    Public Shared Function List() As List(Of GUIAS)
        Try
            Using bd As New gas_gasdesuvecinoEntities
                Return bd.GUIAS.ToList
            End Using
        Catch ex As Exception
            Return Nothing
        End Try
    End Function
    Public Shared Function ListByFacturaId(ByVal zFactutaId As Long) As List(Of GUIAS)
        Try
            Using bd As New gas_gasdesuvecinoEntities
                Dim query = From rec In bd.GUIAS
                          Where rec.FACTURA = zFactutaId
                          Select rec

                Return query.ToList
            End Using
        Catch ex As Exception
            Return Nothing
        End Try
    End Function
   
    Public Shared Function SearchById(ByVal zId As Integer) As GUIAS
        Try
            Using bd As New gas_gasdesuvecinoEntities
                Return bd.GUIAS.Find(zId)
            End Using
        Catch ex As Exception
            Return Nothing
        End Try
    End Function

End Class



